<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登录和注册响应式</title>
    <link rel="stylesheet" href="../content/css/login-style.css">
    <link rel="stylesheet" href="../content/css/popup-box.css" type="text/css" media="all" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    
    <script type="application/x-javascript">
        addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
        function hideURLbar(){ window.scrollTo(0,1); }
	</script>
	
    <script src="../scripts/login/modernizr.js"></script>
    <script src="../scripts/jquery-3.2.1.js"></script>
    <script src="../scripts/crypto-js/core.js"></script>
    <script src="../scripts/crypto-js/md5.js"></script>
    <script>
	$(document).ready(function() {
        $("#submit").click(function () {
            var code = $("#code").val();
            var name = $("#name").val();
            var md5Password = CryptoJS.MD5($("#password").val()).toString(CryptoJS.enc.Hex);
            md5Password = CryptoJS.MD5(md5Password + code).toString(CryptoJS.enc.Hex);
            alert(md5Password+"--"+code);
            $.post("../php/login.php",
                { username: name, password: md5Password, code: code },
                function (result) {
                    var jsonObject=JSON.parse(result);
                    //window.location.href="";
                    //alert("server:"+result + "\n" +"client:"+ CryptoJS.MD5($("#name").val()).toString(CryptoJS.enc.Hex));
                    alert(result);
                    switch(parseInt(jsonObject.code)){
                        case 10001:
                            window.location.href=jsonObject.url;
                            break;
                        case 10002:
                            $("#imgCode").attr("src",jsonObject.url+"?time"+(new Date()).getTime());
                            break;
                        case 10003:
                            $("#imgCode").attr("src",jsonObject.url+"?time"+(new Date()).getTime());
                            break;
                        default:
                            break;
                    }
                });
        });
        $("#imgCode").click(function () {
            var newSrc = "../php/tool/verification.php?time=" + (new Date()).getTime();
            this.src=newSrc;
            return false;
        });
	});
    </script>

</head>
<body>
    <div style="height:100px"></div>
    <div class="w3layouts">
        <div class="signin-agile" style="padding-top:30px;">
            <h2 style="margin-bottom:5px;">登录</h2>
            <label id="login_msg" style="color:red;font-size:14px;"></label>
            <form action="#" method="post">
                <input type="text" name="name" id="name" class="name" placeholder="用户名" required="">
                <input type="password" name="password" id="password" class="password" placeholder="密码" required="">
                    <div><input style="margin-bottom:15px;" type="text" name="code" id="code"  placeholder="验证码" required=""></div>
                    <img src="../php/tool/verification.php" id="imgCode" alt="单击可刷新"/>
                    <label id="code_msg" style="color:red;font-size:14px;"></label>
                <a href="#">忘记密码?</a><br>
                <div class="clear"></div>
                <input style="margin-top:15px" type="button" id="submit" value="登录">
            </form>
        </div>
        <div class="signup-agileinfo">
            <!-- <div class="more">
                <a class="book popup-with-zoom-anim button-isi zoomIn animated" data-wow-delay=".5s" href="#small-dialog">点击注册</a>
            </div> -->
        </div>
        <div class="clear"></div>
    </div>
    <div class="footer-w3l">
        <p class="agileinfo">
        </p>
    </div>
    <div class="pop-up">
        <!-- <div id="small-dialog" class="mfp-hide book-form">
            <h3>注册表单 </h3>
                <form action="#" method="post">
                    <input type="text" name="Name" placeholder="用户名" required=""/>
                    <input type="text" name="Email" class="email" placeholder="邮件" required=""/>
                    <input type="password" name="Password" class="password" placeholder="密码" required=""/>
                    <input type="password" name="Password" class="password" placeholder="重复密码" required=""/>
                    <input type="submit" value="点击注册">
                </form>
        </div> -->
    </div>
</body>
</html>